﻿'***********************************************************************
' Assembly         : SOFA.Caching
' Copyright        : (c) Jebarson. All rights reserved.
' Website			: http://www.jebarson.info
'***********************************************************************

Namespace Caching
    ''' <summary>
    ''' Base type for the entity to be cached.
    ''' </summary>
    Public MustInherit Class StorageItemEntry

#Region " Constructors "
        ''' <summary>
        ''' Initializes a new instance of the <see cref="StorageItemEntry" /> class.	
        ''' </summary>
        Protected Sub New()
        End Sub
#End Region

#Region " Declarations "
        ''' <summary>
        ''' Member variable for the value.
        ''' </summary>
        Private dataValue As Object

        ''' <summary>
        ''' Member variable for the priority.
        ''' </summary>
        Private priorityValue As CachePriority

        ''' <summary>
        ''' Member variable for the last accessed time.
        ''' </summary>
        Private lastAccessedTimeValue As DateTime

        ''' <summary>
        ''' Member variable for the expiry time.
        ''' </summary>
        Private expiryTimeValue As DateTime
#End Region

#Region " Public Properties "
        ''' <summary>
        ''' Gets or sets the key.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>Unique identifier for the object.</remarks>
        Public MustOverride Property Key() As String

        ''' <summary>
        ''' Gets or sets the data.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>The object to be cached.</remarks>
        Public Property Data() As Object
            Get
                Return Me.dataValue
            End Get
            Set(ByVal value As Object)
                Me.dataValue = value
            End Set
        End Property

        ''' <summary>
        ''' Gets or sets the priority.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>The priority of the object cached; The object will scavenged based on the set priority.</remarks>
        Public Property Priority() As CachePriority
            Get
                Return Me.priorityValue
            End Get
            Set(ByVal value As CachePriority)
                Me.priorityValue = value
            End Set
        End Property

        ''' <summary>
        ''' Gets the last accessed time.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>The time the object is last accessed.</remarks>
        Public Property LastAccessedTime() As DateTime
            Get
                Return Me.lastAccessedTimeValue
            End Get
            Set(ByVal value As DateTime)
                Me.lastAccessedTimeValue = value
            End Set
        End Property

        ''' <summary>
        ''' Gets or sets the expiry time.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>The time the object will be removed from the cache.</remarks>
        Public Property ExpiryTime() As DateTime
            Get
                Return Me.expiryTimeValue
            End Get
            Set(ByVal value As DateTime)
                Me.expiryTimeValue = value
            End Set
        End Property
#End Region

    End Class
End Namespace